# -*- coding: utf-8 -*-
# =============================================================================
#     FileName:
#         Desc:
#       Author:
#        Email:
#     HomePage:
#      Version:
#   LastChange:
#      History:
# =============================================================================
import datetime
from dateutil.relativedelta import relativedelta


class DateTimeDiffer(object):
    @classmethod
    def get_diff_days(cls, start_time: datetime.datetime, end_time: datetime.datetime):
        return (end_time - start_time).days

    @classmethod
    def get_diff_weeks(cls, start_time: datetime.datetime, end_time: datetime.datetime):
        return int((end_time - start_time).days / 7)

    @classmethod
    def get_diff_months(cls, start_time: datetime.datetime, end_time: datetime.datetime):
        delta_time = relativedelta(end_time, start_time)
        return delta_time.years * 12 + delta_time.months

    @classmethod
    def get_diff_years(cls, start_time: datetime.date, end_time: datetime.date):
        delta_time = relativedelta(end_time, start_time)
        return delta_time.years


def test():
    start_time = datetime.datetime(year=2024, month=9, day=2, hour=2)
    end_time = datetime.datetime(year=2025, month=9, day=2, hour=1)
    diff_days = DateTimeDiffer.get_diff_days(start_time, end_time)
    print("diff_days:", diff_days)
    diff_weeks = DateTimeDiffer.get_diff_weeks(start_time, end_time)
    print("diff_weeks:", diff_weeks)
    diff_months = DateTimeDiffer.get_diff_months(start_time, end_time)
    print("diff_months:", diff_months)
    diff_years = DateTimeDiffer.get_diff_years(start_time, end_time)
    print("diff_years:", diff_years)


if __name__ == '__main__':
    test()
